﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;

namespace VisualStudioEnv
{
    public class VSProject
    {
        public Project Project { get; set; }
        public string Name { get; private set; }

        public VSProject(Project project)
        {
            this.Project = project;
            this.Name = project.Name;
        }

        public IEnumerable<ProjectItem> EDMXModels
        {
            get
            {
                while (true)
                {
                    try
                    {
                        var enumerator = this.Project.ProjectItems.GetEnumerator();
                        enumerator.MoveNext();

                        break;
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(100);
                        continue;
                    }
                }

                foreach (ProjectItem item in this.Project.ProjectItems)
                {
                    if (item.Name.EndsWith(".edmx"))
                    {
                        yield return item;
                    }
                }
            }
        }
    }
}
